<?php
$this->breadcrumbs=array(
	'综合控制台'=>array($this->pre_module_url.'/index/index'),
	'广告管理'=>array($this->pre_module_url.'/adse/admin'),
	'广告位管理'=>array($this->pre_module_url.'/adzon/admin'),	
	'创建广告位'
);
?>
<?php 
$form = $this->beginWidget('CActiveForm', 
array(
'id'=>'adzone-form',
'enableAjaxValidation'=>true,
'enableClientValidation'=>true,	
'action'=>$this->pre_module_url.'/adzone/createadzone',
)); ?>
<?php echo $form->hiddenField($model,'zdz_associate'); ?>
    <ul class="form_list form_list2 mt10">
        <li class="c_f"><span class="tit">选择所在页面：</span>
            <div id="menubox" class="cont f_l">
            <?php 
				echo CHtml::dropDownList('Adzone[zna_id]',$menu1['zna_id'],Nav::model()->getTopData(),array('class'=>'mr10 s_ipt level_1 w_170','onchange'=>'afterSelect(1,this.value)','id'=>'menuselect1')); 
				if($menu2){
					echo CHtml::dropDownList('Adzone[zna_id2]',$menu2['zna_id'],Nav::model()->getChildData($menu1['zna_id']),array('class'=>'mr10 s_ipt level_1 w_170','onchange'=>'afterSelect(2,this.value)','id'=>'menuselect2')); 
					if($menu3){
						echo CHtml::dropDownList('Adzone[zna_id3]',$menu3['zna_id'],Nav::model()->getChildData($menu2['zna_id']),array('class'=>'mr10 s_ipt level_1 w_170','onchange'=>'afterSelect(3,this.value)','id'=>'menuselect3')); 
					}
				}
			?>
            </div>
        </li>
        <li class="c_f"><span class="tit"><?php echo $form->labelEx($model,'zdz_name'); ?>：</span>
            <div class="cont f_l"><?php echo $form->textField($model,'zdz_name',array('class'=>'t_ipt w_170')); ?></div>
            <span id="zdzname"><?php echo $form->error($model,'zdz_name',array('class'=>'onCorrect d_i c_red2')); ?></span>
        </li>
        <li class="c_f"><span class="tit"><?php echo $form->labelEx($model,'zdz_assist_id'); ?>：</span>
            <div class="cont f_l"><?php echo $form->textField($model,'zdz_assist_id',array('class'=>'t_ipt w_170')); ?></div>
            <span id="zdzassistid"><?php echo $form->error($model,'zdz_assist_id',array('class'=>'onCorrect d_i c_red2')); ?></span>
        </li>
        <li class="c_f"><span class="tit">广告类型：</span>
            <div class="cont f_l"><label class="mr20"><?php echo $form->radioButtonList($model,'zdz_type',array(1=>'图片广告',2=>'flash动画广告'),array('style'=>'margin-left:10px')); ?></label></div>
        </li>
        <li class="c_f">
            <span class="tit"><?php echo $form->label($model,'zdz_desc'); ?>：</span>
            <div class="cont f_l"><?php echo $form->textarea($model,'zdz_desc',array('class'=>'t_area','style'=>'height:65px;width:500px;')); ?></div>
            <span id="zdzdesc"><?php echo $form->error($model,'zdz_desc',array('class'=>'onCorrect d_i c_red2')); ?></span>
        </li>
        <li class="c_f"><span class="tit"><?php echo $form->labelEx($model,'zdz_price'); ?>：</span>
            <div class="cont f_l"><?php echo $form->textField($model,'zdz_price',array('class'=>'t_ipt w_170','value'=>'','maxlength'=>10)); ?></div>
            <span id="zdzprice"><?php echo $form->error($model,'zdz_price',array('class'=>'onCorrect d_i c_red2')); ?></span>
        </li>
        <li class="c_f"><span class="tit">可见会员组：</span>
            <div class="cont fl">
            全部会员组  <input name="member" type="radio" value="0" style="margin-right:10px;" onchange="adapt(this);" checked/> 
            部分会员组<input name="member" type="radio" value="1" onchange="adapt(this);" />
                <div class="cont d_n" id="groupbox" style="margin-top:10px;padding-left:100px;">
                    <?php
                        foreach($grouplist as $key=>$value){
                            echo '<input type="checkbox" name="Adzone[zmg_id][]" value="'.$key.'">'.$value.'<span  style="margin-left:15px;width:1px;"></span>';
                        }
                    ?>
                </div>
            </div>
        </li>
        <li class="c_f"><span class="tit"><?php echo $form->labelEx($model,'zdz_width'); ?>：</span>
            <div class="cont f_l"><?php echo $form->textField($model,'zdz_width',array('class'=>'t_ipt w_100','value'=>'','maxlength'=>5)); ?>px</div>
            <span id="zdzwidth"><?php echo $form->error($model,'zdz_width',array('class'=>'onCorrect d_i c_red2')); ?></span>
        </li>
        <li class="c_f"><span class="tit"><?php echo $form->labelEx($model,'zdz_height'); ?>：</span>
            <div class="cont f_l"><?php echo $form->textField($model,'zdz_height',array('class'=>'t_ipt w_100','value'=>'','maxlength'=>5)); ?>px</div>
            <span id="zdzheight"><?php echo $form->error($model,'zdz_height',array('class'=>'onCorrect d_i c_red2')); ?></span>
        </li>
        <li class="c_f"><span class="tit"><?php echo $form->labelEx($model,'zdz_max_ads'); ?>：</span>
            <div class="cont f_l"><?php echo $form->textField($model,'zdz_max_ads',array('class'=>'t_ipt w_100','value'=>'','maxlength'=>5)); ?></div>
            <span id="zdzmaxads"><?php echo $form->error($model,'zdz_max_ads',array('class'=>'onCorrect d_i c_red2')); ?></span>
        </li>
        <li class="c_f"><span class="tit">&nbsp;</span>
            <div class="cont f_l"><input class="mem_btn mem_btn18 mr5" type="submit" name="" value="保存" /><input class="mem_btn mem_btn07" type="submit" name="" value="取 消" /></div>
        </li>
    </ul>	
<?php $this->endWidget(); ?>
<script>
	function adapt(obj){
		if(obj.value==1 && obj.checked){
			$('#groupbox').show();
		}else if(obj.value==0 && obj.checked){
			$('#groupbox').hide();
		}
	}
	function afterSelect(level,menuid){
		$('#menuselect'+level).nextAll().remove();
		menuid = parseInt(menuid)==0 ? -1 : menuid;
		$.getJSON("/manage/nav/getchildmenu", { menuid: menuid, level: level }, function(data){
			if(data.amount>1){
				var nextLevel=parseInt(data.level)+1;
				var next = '<select class="level_'+(nextLevel)+' mr10 s_ipt w_170" onchange="afterSelect('+(nextLevel)+',this.value)" id="menuselect'+(nextLevel)+'" name="Adzone[zna_id'+(nextLevel)+']">';
				$.each(data.items, function(i,item){
					next += '<option value="'+i+'">'+item+'</option>';
				});
				next += '</select>';
				$('#menuselect'+data.level).after(next);
			}
		});
	}
</script>